package myalg.graphs;

import java.awt.*;

/**
 * @author Pavel Belevich
 *         Date: Jun 13, 2012
 *         Time: 2:14:35 PM
 */
public class Edge {

    private Vertex v1;
    private Vertex v2;
    private Color color = Color.BLACK;
    private String caption;

    public Edge() {
    }

    public Edge(Vertex v1, Vertex v2) {
        this.v1 = v1;
        this.v1.getEdges().add(this);
        this.v2 = v2;
        this.v2.getEdges().add(this);
    }

    public Edge(Vertex v1, Vertex v2, Color color) {
        this.v1 = v1;
        this.v2 = v2;
        this.color = color;
    }

    public Edge(Vertex v1, Vertex v2, String caption) {
        this.v1 = v1;
        this.v2 = v2;
        this.caption = caption;
    }

    public Edge(Vertex v1, Vertex v2, Color color, String caption) {
        this.v1 = v1;
        this.v2 = v2;
        this.color = color;
        this.caption = caption;
    }

    public Vertex getV1() {
        return v1;
    }

    public void setV1(Vertex v1) {
        this.v1 = v1;
    }

    public Vertex getV2() {
        return v2;
    }

    public void setV2(Vertex v2) {
        this.v2 = v2;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public String getCaption() {
        return caption;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    public Vertex getAdjacent(Vertex v) {
        return v == v1 ? v2 : v1;
    }
}
